#! /usr/bin/env python
# -*- coding: utf-8 -*-

# *************************************************************
#     Filename @  get_server_file.py
#       Author @  Huoty
#  Create date @  2016-04-07 15:35:57
#  Description @  
# *************************************************************

import os
import sys

USER = "xxx"
HOST_IP = "xxx.xxx"

# Script starts from here

if len(sys.argv) != 3:
    print "Usage:\tget-server-file <remote file path> <local path>"
    sys.exit(1)

weave = [ 
    "scp",  # main command
    USER + "@" + HOST_IP + ":" +  # host address
    sys.argv[1],  # remote file path
    sys.argv[2]  # local path
]

cmd = " ".join(weave); print cmd
ret = os.system(cmd)

if ret:
    print "Failed to get server file!"
else:
    print "Local file place: ", sys.argv[2]
